package com.nx.samuel.callback_demo.consumer;

import com.nx.samuel.callback_demo.api.CallbackListener;
import com.nx.samuel.callback_demo.api.CallbackService;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class CallbackConsumer {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-consumer.xml");
        context.start();

        CallbackService callbackService = context.getBean("callbackService", CallbackService.class);
        // 增加listener;new CallbackListener时回调的具体实现，在消费端通过匿名内部类的方式实现的
        callbackService.addListener("foo.bar", new CallbackListener() {
            private Integer integer = 1;
            @Override
            public void changed(String msg) {
                System.out.println("I am callback:" + msg);
            }
        });
        System.in.read();
    }

}
